﻿<%@ Page Language="C#" MasterPageFile="~/Site.master" 
CodeFile="ControlFilterExpression.aspx.cs" Inherits="ControlFilterExpressionSample" %>

<%@ Register src="~/DynamicData/Content/GridViewPager.ascx" tagname="GridViewPager" tagprefix="asp" %>

<asp:Content ID="headContent" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true" />

    
    <h2 class="DDSubHeader">Displaying Detailed Information of a Selected  <%= GridDataSource.GetTable().DisplayName%> Table Item</h2>
        
    <div class="ExampleView"> 
	    On any row in the <code><%=GridDataSource.GetTable().DisplayName%></code> table click select 
        to display detailed information for the selected item.<br /> 
	    The example uses the 
        <a href="http://msdn.microsoft.com/en-us/library/system.web.dynamicdata.controlfilterexpression(VS.100).aspx" target="_blank">
	    <code>System.Web.DynamicData.ControlFilterExpression</code></a> control to obtain the 
        details about the selected item. 
    </div>
    
    <hr />
    
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
                HeaderText="Vui lòng sửa lại các lỗi dưới đây" />
            <asp:DynamicValidator runat="server" ID="GridViewValidator" ControlToValidate="GridView1" Display="None" />
            <asp:DynamicValidator runat="server" ID="DetailsViewValidator" ControlToValidate="DetailsView1" Display="None" />

            <asp:GridView ID="GridView1" runat="server" DataSourceID="GridDataSource" EnablePersistedSelection="true"
                AutoGenerateSelectButton="True" AutoGenerateEditButton="True" AutoGenerateDeleteButton="true"
                AllowPaging="True" AllowSorting="True" OnDataBound="OnGridViewDataBound"
                OnRowEditing="OnGridViewRowEditing" OnSelectedIndexChanging="OnGridViewSelectedIndexChanging"
                OnRowDeleted="OnGridViewRowDeleted" OnRowUpdated="OnGridViewRowUpdated"
                OnRowCreated="OnGridViewRowCreated" PageSize="5" CssClass="DDGridView">

                <PagerStyle CssClass="footer" />        
                <SelectedRowStyle CssClass="selected" />
                <PagerTemplate>
                    <asp:GridViewPager runat="server" />
                </PagerTemplate>
                <EmptyDataTemplate>
                    Chưa có dữ liệu.
                </EmptyDataTemplate>
            </asp:GridView>

              
            <asp:EntityDataSource ID="GridDataSource" runat="server" 
                EnableDelete="True" EnableUpdate="True" 
                ContextTypeName="ITPCTaxFormModel.ITPCTaxFormEntities1" 
                EnableFlattening="False" 
                EntitySetName="Products"  />
                
            <h2 class="DDSubHeader"><%= DetailsDataSource.GetTable().DisplayName%> Details</h2>
   
            <asp:Panel ID="DetailsPanel" runat="server">
         
                <asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="DetailsDataSource"
                    AutoGenerateEditButton="true" AutoGenerateDeleteButton="true" AutoGenerateInsertButton="true"
                    OnModeChanging="OnDetailsViewModeChanging" OnPreRender="OnDetailsViewPreRender"
                    OnItemDeleted="OnDetailsViewItemDeleted" OnItemUpdated="OnDetailsViewItemUpdated"
                    OnItemInserted="OnDetailsViewItemInserted" CssClass="DDDetailsTable" FieldHeaderStyle-CssClass="bold">
                </asp:DetailsView>
                 
                <asp:EntityDataSource ID="DetailsDataSource" runat="server" 
                EnableDelete="True" EnableUpdate="True" EnableInsert="True"
                ContextTypeName="ITPCTaxFormModel.ITPCTaxFormEntities1" 
                EnableFlattening="False" 
                EntitySetName="Products"  />
                
                <asp:QueryExtender TargetControlID="DetailsDataSource" runat="server">
                    <asp:ControlFilterExpression ControlID="GridView1" />
                </asp:QueryExtender>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
